package com.Day1009;

import java.io.*;

public class Text10 {
    public static void main(String[] args) throws Exception {
        Student student = new Student("张三","1001",18);
        File file = new File("F:\\Java\\c.txt");
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
        objectOutputStream.writeObject(student);
        objectOutputStream.close();
        fileOutputStream.close();
        //  读取
        FileInputStream fileInputStream = new FileInputStream(file);
        ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
        Student studentR = (Student)objectInputStream.readObject();
        System.out.println(studentR.getAge());
        System.out.println(studentR.getId());
        System.out.println(studentR.getName());
        objectInputStream.close();
        fileInputStream.close();
    }
}
